import React from 'react';
import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
import SideNav from '../components/SideNav';
import AIChatPage from '../pages/AIChatPage';
import AppsPage from '../pages/AppPage';
import Shouye from '../pages/shouye';
import Kongzhi from '../pages/Kongzhi';
import DashboardPage from '../components/Dataset/Dashboard';
import Bootpage from '../components/bootpage'
import { ThemeProvider } from '../contexts/ThemeContext';
import App from '../App';
import AlarmPage from '../pages/AlarmPage';
import VideoPage from '../pages/VideoPage';
import SmartVideoPage from '../pages/SmartVideoPage';

// 创建一个空的爬虫工具页面组件
const CrawlerPage: React.FC = () => {
  return (
    <div style={{ padding: '20px' }}>
      <h1>爬虫工具</h1>
      <p>请选择左侧子菜单查看具体内容</p>
    </div>
  );
};

const AppRouter: React.FC = () => {
  return (
    <Router>
      <ThemeProvider>
        <Routes>
          {/* 启动页面 */}
          <Route path="/" element={<Bootpage />} />
          
          {/* 默认重定向到主应用页面 */}
          <Route path="/app" element={<App />} />
          
          {/* SideNav作为主框架，包含其他子页面 */}
          <Route path="/SideNav" element={<SideNav />}>
            <Route path="shouye" element={<Shouye />} />
            <Route path="ai-chat" element={<AIChatPage />} />
            <Route path="apps" element={<AppsPage />} />
            <Route path="kongzhi" element={<Kongzhi />} />
            {/* 爬虫工具父路由 */}
            <Route path="crawler" element={<CrawlerPage />} />
            <Route path="alarm" element={<AlarmPage />} />
            <Route path='Dashboard' element={<DashboardPage />} />
            <Route path='video' element={<VideoPage />} />
            <Route path='smart-video' element={<SmartVideoPage />} />
          </Route>
          
          {/* 默认路由重定向到/app */}
          <Route path="*" element={<Navigate to="/app" replace />} />
        </Routes>
      </ThemeProvider>
    </Router>
  );
};

export default AppRouter;